#include "labels.h"

Labels::Labels()
{

    this->labnum=Toy_Num;


}

Labels::Labels(QWidget *parent)
{

       this->labnum=Toy_Num;
       this->labw=Toy_W;
       this->labh=ToY_H;

      for(int i=0;i<Toy_Num;i++){

        this->labsw[i].setParent(parent);
        this->labsw[i].setEnabled(true);
        this->labsw[i].resize(Toy_W,ToY_H);
        this->labsw[i].setScaledContents(true);
        this->labsw[i].clear();
        this->labsw[i].hide();
        this->labsw[i].setStyleSheet("QLabel{ background:yellow}");

      }






}

void Labels::loadpix(QPixmap pix)
{

     for(int i=0;i<this->labnum;i++){

       if(this->labsw[i].isEnabled()){

           this->labsw[i].setPixmap(pix);
//           this->labsw[i].show();
           this->labsw[i].setEnabled(false);
           break;

       }


     }





}

void Labels::clearsw()
{


    for(int i=0;i<this->labnum;i++){


     this->labsw[i].setEnabled(true);
     this->labsw[i].clear();
     this->labsw[i].hide();



    }





}

void Labels::showtoy()
{
    for(int i=0;i<this->labnum;i++){

      if(!this->labsw[i].isEnabled()){
          this->labsw[i].show();
          this->labsw[i].setEnabled(true);

      }

    }




}

void Labels::setpos(QWidget *p)
{

    for(int i=0;i<this->labnum;i++){

      if(i>4){
       this->labsw[i].move(25+(i-5)*(this->labw+100),p->height()/4-60+this->labh);

   }

      else{

      this->labsw[i].move(25+i*(this->labw+100),p->height()/4-60);

      }

    }




}
